//
//  HomeTableHeaderView.swift
//  DaRings
//
//  Created by HFY on 2022/10/30.
//

import UIKit
import MYModule
import SwiftDate

class HomeTableHeaderView: View {
    
    var date: Date? {
        
        didSet {
            
            guard let date = date else {
                return
            }
            
            dateLabel.text = date.localStringOfMonthWeek
            
            guard let hour = Int(date.localString(dateFormat: "HH")) else {
                return
            }
            
            if hour < 12 {
                titleLabel.text = "good_morning".language
            } else if hour < 18 {
                titleLabel.text = "good_afternoon".language
            }  else {
                titleLabel.text = "good_evening".language
            }
            
        }
        
    }
    
    let dateLabel = Label()
    
    let titleLabel = Label()

    override func makeUI() {
        super.makeUI()
        
        addSubview(dateLabel)
        addSubview(titleLabel)
        
        dateLabel.textColor = UIColor.assist_222222
        dateLabel.font = Fonts.systemFont(ofSize: 18)
        
        titleLabel.numberOfLines = 0
        titleLabel.textColor = UIColor.assist_222222
        titleLabel.font = Fonts.boldSystemFont(ofSize: 40)
        
       
        dateLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.top.equalToSuperview().offset(20)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(16)
            make.right.equalToSuperview()
            make.top.equalTo(dateLabel.snp.bottom).offset(10)
            make.bottom.equalToSuperview().offset(-20)
        }
        
    }
    

}
